Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added retry backoff for google-ads unauthorised error #83

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

somethingmorerelevant
Copy link
Member

@somethingmorerelevant somethingmorerelevant commented May 25, 2023

Description of change

This adds retry for intermittent 401 auth errors
Jira: TDL-23120

QA steps

  • automated tests passing
  • manual qa steps passing

Risks

Rollback steps

  • revert this branch

@somethingmorerelevant somethingmorerelevant marked this pull request as ready for review May 26, 2023 08:42
@@ -230,13 +230,14 @@ def on_giveup_func(err):
@backoff.on_exception(backoff.expo,
(GoogleAdsException,
ServerError, TooManyRequests,
ReadTimeout,
ReadTimeout,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this space really needed?

AttributeError),
max_tries=5,
jitter=None,
giveup=should_give_up,
on_giveup=on_giveup_func,
logger=None)
@backoff.on_exception(backoff.expo, Unauthorized, max_tries=5, jitter=None,logger=None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we append Unauthorized in 1st backoff itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the above exceptions have a on_giveup handler, which is not needed and does not work with this specific exception class hence added a new decorator

Comment on lines +107 to +110
try:
make_request(mocked_google_ads_client, "", "")
except Unauthorized:
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use self.assertRaises instead of try-catch block

@@ -7,7 +7,7 @@
from singer import utils, metrics
from google.protobuf.json_format import MessageToJson
from google.ads.googleads.errors import GoogleAdsException
from google.api_core.exceptions import ServerError, TooManyRequests
from google.api_core.exceptions import ServerError, TooManyRequests, Unauthorized

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the error in CCI logs, the import has to be Unauthenticated

@RushiT0122 RushiT0122 self-requested a review June 13, 2023 03:50
Copy link

@RushiT0122 RushiT0122 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we don't retry unauthorised error, so I would like to hold this PR from merging into the master until we have a proof that fix indeed works.

Also can you add possible explanation for the occurrence of this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants